<template>
  <div>
    <template v-if="show"><slot name="btn" /></template>
  </div>
</template>

<script>
export default {
  props: {
    permission: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      show: false
    }
  },
  created() {
    this.checkPermission()
  },
  mounted() {

  },
  methods: {
    checkPermission() {
      if (!this.permission) {
        throw new Error('权限标识不能为空!')
      }
      var permissionList = this.$store.state.user.btnPermissions
      if (permissionList != null && permissionList.length > 0) {
        if (permissionList.includes(this.permission)) {
          // el.parentNode && el.parentNode.removeChild(el)
          this.show = true
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">

</style>
